
export default {
  namespaced: true,
  state: {
    channels: [],
    allChannels: []
  },
  getters: {
    optionalChannels (state) {
    //   return state.allChannels.filter(item => state.channels.map(v => v.id !== item.id))
      return state.allChannels.filter(item => state.channels.findIndex(v => v.id === item.id) === -1)
    //   return state.allChannels.filter(item => {
    //     let flag = true
    //     state.channels.forEach(v => {
    //       if (v.id === item.id) {
    //         flag = false
    //       }
    //     })
    //     return flag
    //   })
    }
  },
  mutations: {
    setChannels (state, value) {
      state.channels = value
    },
    setAllChannels (state, allChannels) {
      state.allChannels = allChannels
    },
    AddMyChannel (state, value) {
      state.channels.push(value)
    },
    removeChannel (state, index) {
      state.channels.splice(index, 1)
    }

  },
  actions: {

  },
  modules: {
  }
}
